package com.example.javachatroomextend.service;

import com.example.javachatroomextend.mapper.SessionMapper;
import com.example.javachatroomextend.model.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SessionService {
    @Autowired
    private SessionMapper sessionMapper;

    public List<Integer> getSessionListByUserId(Integer userId) {
        return sessionMapper.getSessionIdByUserId(userId);
    }

    public Integer getFriendUserIdBySessionId(Integer sessionId,Integer selfId) {
        return sessionMapper.getFriendUserIdBySessionId(sessionId,selfId);
    }

    public Session getSessionBySessionId(Integer sessionId) {
        return sessionMapper.getSessionBySessionId(sessionId);
    }

    public void createSession(Session session) {
        sessionMapper.createSession(session);
    }

    public Integer addSessionUser(Integer sessionId,Integer userId) {
        return sessionMapper.addSessionUser(sessionId,userId);
    }

    public Integer updateLastTimeAndLastMessage(String lastTime,String lastMessage,Integer sessionId) {
        return sessionMapper.updateLastTimeAndLastMessage(lastTime,lastMessage,sessionId);
    }

    public List<Integer> getSessionIdByUserName(String username,Integer userId) {
        return sessionMapper.getSessionIdByUserName(username,userId);
    }
}
